<?php


namespace app\common\model;


class History extends Base
{
    public function type_select_media ($user_id,$history_type,$nowPage=1,$limits=10)
    {
        if(!isset($user_id) || !is_numeric($user_id) || $history_type != 1 && $history_type != 2) {
            exception('非法传参');
        }
        $data = [
            'user_id' => $user_id,
            'media_type' => $history_type
        ];
        $order = [
            'create_time' => 'desc'
        ];
        return $this->where($data)->order($order)->page($nowPage,$limits)->select();
    }

    public function type_count_media ($user_id,$history_type)
    {
        $data = [
            'user_id' => $user_id,
            'media_type' => $history_type
        ];
        return $this->where($data)->count();
    }
}